package school.person;

import java.util.ArrayList;
import java.util.List;
import school.course.Course;
import school.person.Teacher;

public class Student extends Person {
    private List<String> courseIds = new ArrayList<>();

    // 子类构造方法，使用super调用父类构造
    public Student(String studentId, String studentName, String gender) {
        super(studentId, studentName, gender);
    }

    // 选课方法
    public boolean selectCourse(String courseId) {
        if (!courseIds.contains(courseId)) {
            courseIds.add(courseId);
            return true;
        }
        return false;
    }

    // 退课方法
    public boolean dropCourse(String courseId) {
        return courseIds.remove(courseId);
    }

    // 实现父类抽象方法：打印学生课表
    @Override
    public void printWorksheet() {
        System.out.println("学生 " + getName() + " 的课表:");
    }

    // Getter
    public List<String> getCourseIds() {
        return courseIds;
    }

    @Override
    public String toString() {
        return "学生编号: " + id + ", 学生姓名: " + getName() + ", 性别: " + gender + ", 所选课程编号: " + courseIds;
    }
}